package com.xhh.adjust.feign;

import com.xhh.adjust.service.AdjustService;
import com.xhh.adjust.service.FaultyService;
import com.xhh.adjust.service.MajorService;
import com.xhh.model.adjust.dtos.GetAdjustDto;
import com.xhh.model.adjust.dtos.GetMajorDto;
import com.xhh.model.common.dtos.ResponseResult;
import lombok.RequiredArgsConstructor;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/adjust")
@RequiredArgsConstructor
public class AdjustClient {

    private final FaultyService faultyService;

    @GetMapping("/faulty/{faultyCode}")
    ResponseResult getFaultyByCode(@PathVariable("faultyCode") String faultyCode){
        return faultyService.getFaultyByCode(faultyCode);
    }

    private final MajorService majorService;

    /**
     * 根据专业编码获取专业信息
     * @param majorCode
     * @return
     */
    @GetMapping("/major/{majorCode}")
    ResponseResult getMajorByCode(@PathVariable("majorCode") String majorCode) {
        return majorService.getMajorByCode(majorCode);
    }

    /**
     * 获取院系列表
     * @param unityId
     * @return
     */
    @GetMapping("/faultyList/{unityId}")
    ResponseResult getFaultyByUnityId(@PathVariable("unityId") Long unityId) {
        return faultyService.getFaultyByUnityId(unityId);
    }

    /**
     * 根据单位id和院系id获取专业列表
     * @param dto
     * @return
     */
    @GetMapping("/major/getMajorByUidAndFid")
    ResponseResult getMajorByUidAndFid(@SpringQueryMap GetMajorDto dto) {
        return majorService.getMajorByUidAndFid(dto);
    }

    private final AdjustService adjustService;

    /**
     * 根据单位编码、院系编码、专业编码查询缺额信息
     * @param dto
     * @return
     */
    @GetMapping("/getAdjustByCode")
    ResponseResult getAdjustByCode(@SpringQueryMap GetAdjustDto dto) {
        return adjustService.getAdjustByCode(dto);
    }
}
